<?php

/**
 * Discuz项目公共Action
 */
class DiscuzAction extends Action {

    //各种缓存 比如当前登陆用户信息等
    public static $Cache = array();
    public $tpl;
    public $_tpl_vars = array();

    function _initialize() {
        global $_G;
        //设置导航焦点对应到文件名中
        if (isset($_G['setting']['navmn'][$_G['basefilename']])) {
            $_G['mnid'] = $_G['setting']['navmn'][$_G['basefilename']];
        }
        $this->assign("waitSecond", 2000);
    }

    function success($message, $jumpUrl = '', $ajax = false) {
        showmessage($message, $jumpUrl);
    }

    function assign($name, $value = null) {
        if ($name == '')
            return false;
        if (is_null($value)) {
            $name = explode(",", $name); //print_r($name);
            for ($i    = 0, $n    = count($name); $i < $n; $i++) {
                if ($name[$i] != '')
                    $this->_tpl_vars[$name[$i]] = $GLOBALS[$name[$i]];
            }
        } else {
            $this->_tpl_vars[$name] = $value;
        }
    }

    public function diy($file = '', $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl = '') {
        global $_G;
        extract($this->_tpl_vars);
        eval(display("diy:" . $file, $templateid, $tpldir, $gettplfile, $primaltpl));
    }

    public function display($file = '', $templateid = 0, $tpldir = '', $gettplfile = 0, $primaltpl = '') {
        global $_G;
        extract($this->_tpl_vars);
        eval(display($file, $templateid, $tpldir, $gettplfile, $primaltpl));
    }

    public function ajaxSuccess($msg, $data) {
        $data = reStatus(true, $msg, $data);
        $this->ajaxReturn($data);
    }

    public function ajaxError($msg, $data) {
        $data = reStatus(false, $msg, $data);
        $this->ajaxReturn($data);
    }

}

?>
